package com.david.viewtest

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.scwang.smart.refresh.layout.SmartRefreshLayout

class RefreshTestActivity: AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_refresh)
        //系统刷新view, 参考链接：https://blog.csdn.net/fjnu_se/article/details/106687692
        //findViewById<SwipeRefreshLayout>(R.id.refresh)?.let {
        //    it.setOnRefreshListener {
        //        it.postDelayed({
        //                       it.isRefreshing = false
        //        }, 1500)
        //    }
        //}


        //自定义header及footer：https://github.com/scwang90/SmartRefreshLayout/blob/master/art/md_custom.md
        findViewById<SmartRefreshLayout>(R.id.smart_refresh).let { view ->
            view.setOnRefreshListener {
                view.postDelayed({
                    view.finishRefresh()
                }, 1500)
            }
            view.setOnLoadMoreListener { view.postDelayed({
                view.finishLoadMore()
            }, 1500) }
        }
    }
}